import Vue from 'vue'

const formatTime = (time, mat) => {
  if (!time) return
  const date = new Date(time)
  let y = date.getFullYear()
  let m = date.getMonth() + 1;
  let d = date.getMonth()
  let h = date.getHours()
  let f = date.getMinutes()
  let s = date.getSeconds()

  m = m < 10 ? `0${m}` : m
  d = d < 10 ? `0${d}` : d
  h = h < 10 ? `0${h}` : h
  f = f < 10 ? `0${f}` : f
  s = s < 10 ? `0${s}` : s
  // const 
  if (mat == "yy-mm-dd") {
    return `${y}-${m}-${d}`
  } else if (mat == "yy-mm-dd,hh:mm") {
    return `${y}-${m}-${d} ${h}:${f}:${s}`
  }

}


Vue.filter('formatTime', formatTime)

